import java.util.HashMap;

class Solution1 {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> hash = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int x = target - nums[i];
            if (hash.containsKey(x)) {
                return new int[] {hash.get(x), i};
            }
            hash.put(nums[i], i);
        }
        return new int[] {-1, -1};
    }
}